<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <%@ include file="/common/pre/header.jsp" %>
    <script src="${ctx}/statics/js/cart/cart.js"></script>
    <title>易买网</title>
</head>
<body>
<!--Begin Header Begin-->
<div id="searchBar">
    <%@ include file="/common/pre/searchBar.jsp" %>
</div>
<!--End Header End-->
<!--Begin Menu Begin-->
<div class="menu_bg">
    <div class="menu">
        <!--Begin 商品分类详情 Begin-->
        <%@ include file="/common/pre/categoryBar.jsp" %>
        <!--End 商品分类详情 End-->
    </div>
</div>
<!--End Menu End-->
<div class="i_bg">
    <div id="settlement" style="margin-left: 150px;">
    </div>
    <div class="content mar_20">
        <img src="${ctx}/statics/images/img2.jpg"/>
    </div>
    <div class="content mar_20">
        <div class="two_bg">
            <div class="two_t">
                <span class="fr"><a href="javascript:void(0);" onclick="settlement1();">修改</a></span>商品列表
            </div>
            <table border="0" class="car_tab" style="width:1110px;" cellspacing="0" cellpadding="0">
                <tr>
                    <td class="car_th" width="550">商品名称</td>
                    <td class="car_th" width="150">购买数量</td>
                    <td class="car_th" width="130">小计</td>
                </tr>
                <c:forEach items="${listCarSession}" var="temp">
                    <tr>
                        <td>
                            <div class="c_s_img">
                                <img src="${temp.img}" width="73" height="73"/>
                            </div>
                                ${temp.name}
                        </td>
                        <td align="center">${temp.num}</td>
                        <td align="center" style="color:#ff4e00;">￥${temp.price}</td>
                    </tr>
                </c:forEach>
            </table>

            <div class="two_t">
                <span class="fr"></span>收货人信息
            </div>
            <table border="0" class="peo_tab" style="width:1110px;" cellspacing="0" cellpadding="0">
                <tr>
                    <td class="p_td" width="160">用户名称</td>
                    <td width="395">${sessionUser.userName}</td>
                    <td class="p_td">登录名称</td>
                    <td>${sessionUser.loginName}</td>
                </tr>
                <tr>
                    <td class="p_td">手机</td>
                    <td>${sessionUser.mobile}</td>
                    <td class="p_td" width="160">电子邮件</td>
                    <td width="395">${sessionUser.email}</td>
                </tr>
            </table>
            <div class="two_t">
                <span class="fr"></span>选择地址
            </div>
            <table border="0" class="peo_tab" style="width:1110px;" cellspacing="0" cellpadding="0">
                <c:forEach items="${listAddress}" var="temp" varStatus="status">

                   <%-- <tr>
                        <td class="p_td" width="160">
                            地址：${temp.address}
                        </td>
                        <td>
                            备注：${temp.remark}
                        </td>
                    </tr>
--%>
                    <tr>
                        <td class="p_td" width="160">
                            <c:choose>
                                <c:when test="${empty temp.remark}">
                                    地址${status.index+1}
                                </c:when>
                                <c:otherwise>
                                    ${temp.remark}
                                </c:otherwise>
                            </c:choose>
                            <input type="radio" name="selectAddress" id="selectAddress" value="${temp.address}">
                        </td>
                        <td>
                                ${temp.address}
                        </td>
                    </tr>
                </c:forEach>
                <tr>
                    <td class="p_td" width="160">
                        新地址<input type="radio" name="selectAddress" value="-1">
                    </td>
                    <td>
                        地址&nbsp;<input type="text" value="" name="address" id="address" class="add_ipt">&nbsp;
                        备注&nbsp;<input type="text" value="" name="remark" id="remark" class="add_ipt">
                    </td>
                </tr>
            </table>
            <table border="0" style="width:900px; margin-top:20px;" cellspacing="0" cellpadding="0">
                <tr height="70">
                    <td align="right">
                        <b style="font-size:14px;">应付款金额：<span
                                style="font-size:22px; color:#ff4e00;">￥${sum}</span></b>
                    </td>
                </tr>
                <tr height="70">
                    <td align="right"><a href="#"><img src="${ctx}/statics/images/btn_sure.gif" onclick="addOrder()"/></a></td>
                </tr>
            </table>
        </div>
    </div>
    <%@ include file="/common/pre/footer.jsp" %>
</div>
</body>
<script>
    function addOrder() {
        let address = document.getElementById("address").value;
        let remark = document.getElementById("remark").value;
        let selectAddress = document.getElementsByName("selectAddress");
        var address2="";
        for (let i = 0; i < selectAddress.length ; i++) {
            if(selectAddress[i].checked){
                address2=selectAddress[i].value;
            }
        }
        window.location="/addOrderServlet?address="+address+"&&remark="+remark+"&&address2="+address2+"&&sum=${sum}";
    }
</script>
</html>
